package com.yzf.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.yzf.entity.Idea;
import com.yzf.entity.IdeaComment;
import com.yzf.entity.Project;
import com.yzf.service.IdeaService;
import com.yzf.util.util.DateTimeUtil;
import com.yzf.util.web.ServletUtil;

public class IdeaShowServlet extends HttpServlet {

	
	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		HttpSession session = ServletUtil.getSession(request);
		Project project = (Project)session.getAttribute("project");
		
		IdeaService service = new IdeaService();
		List<Idea> ideaList = service.findByPid(project.getId());
		
		for (int i = 0; i < ideaList.size(); i++) {
			
			Idea idea = ideaList.get(i);
			String time = idea.getCreatetime();
			
			String time2 = DateTimeUtil.getTimeForShowing(time);
			idea.setTime(time2);
		}

		
		session.setAttribute("ideaList", ideaList);
		
		ServletUtil.forword(request, response, "idea");
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		
	}

}
